<template>
  <div class="card-items">
    <div class="head-part">
      <div class="title">
        <img src="@/assets/van-img.png" alt="" />
        <span>分公司地市情况</span>
      </div>
    </div>

    <div class="report-head">
      <div
        class="head"
        :style="{
          background: colors[index].background,
          color: colors[index].color,
        }"
        v-for="(item, index) in titles"
        :key="index"
      >
        {{ item }}
      </div>
    </div>
    <div class="report-content" v-for="(item, index) in areas" :key="index">
      <div
        class="row"
        :style="{
          color: colors[iIndex].color,
        }"
        v-for="(iItem, iIndex) in item"
        :key="iIndex"
      >
        {{ iItem }}
      </div>
    </div>
  </div>
</template>
<script>
import { Toast } from "vant";
import { reactive, toRefs, onMounted } from "vue";
export default {
  props: ["itemObj"],
  setup(props) {
    let item = props.itemObj;
    const state = reactive({
      titles: item.titles,
      areas: item.areas,
      colors: item.colors,
    });

    onMounted(() => {
      let listData = state.areas;
      if (listData.length <= 0) {
        Toast("无地市数据");
        return;
      }
    });
    return {
      ...toRefs(state),
    };
  },
};
</script>
<style lang="scss" scoped>
.card-items {
  margin: 10px;
  width: calc(100% - 20px);
  background-color: #fff;
  border-radius: 5px;
  padding: 10px 0 2px 10px;
  margin-bottom: 10px;
  .head-part {
    width: 100%;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    .qs-text {
      padding: 0 15px;
      line-height: 24px;
      color: #666666;
      margin-right: 10px;
      font-size: 12px;
      background: #ffffff;
      box-shadow: 0px 0px 2px 0px rgba(0, 0, 0, 0.2);
      border-radius: 4px;
    }
  }
  .title {
    width: 50%;
    display: flex;
    align-items: center;
    span {
      font-size: 16px;
      font-weight: 400;
      color: #333333;
    }
  }

  .value {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 96px;
    height: 24px;
    background: #fffaf4;
    border-radius: 4px;
    font-size: 14px;
    font-family: Helvetica-Bold, Helvetica;
    font-weight: bold;
    color: #fe6a00;
    line-height: 17px;
  }

  .report-head {
    margin: 8px;
    width: calc(100% - 16px);
    display: flex;
    height: 28px;

    .head {
      width: 16%;
      height: 28px;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 13px;
      font-family: PingFangSC-Regular, PingFang SC;
      font-weight: 400;
    }
  }

  .report-content {
    margin-left: 8px;
    margin-right: 8px;
    width: calc(100% - 16px);
    display: flex;
    height: 28px;

    .row {
      width: 16%;
      height: 28px;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 13px;
      font-family: PingFangSC-Regular, PingFang SC;
      font-weight: 400;
      border-bottom: 1px solid #f3f3f3;
    }
  }
}
</style>
